package Mapstruct.convert;

import Mapstruct.dto.StudentDto;
import Mapstruct.vo.StudentVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.text.NumberFormat;

/**
 * 对于同名，同类型可以自动映射
 */
@Mapper
public interface StudentConvert {
    StudentConvert INSTANCE = Mappers.getMapper(StudentConvert.class);

    /**
     * StudentDto -> StudentVo
     */
    @Mappings({
            @Mapping(source = "studentName", target = "studentName"),
            @Mapping(source = "phone", target = "phone", numberFormat = "#"),
            @Mapping(source = "count", target = "count", numberFormat = "#.00")
    })
    StudentVo dtoToVo(StudentDto studentDto);
}
